import time
from public.action import *
from public.business import *
from public.testData import *
from public.tools import *

testCase = "DBshop014_商品管理管理分类商品分类删除分类"

#登入后台
firefox=openBrowser(urlAdmin)
firefox.get(urlAdmin)
DBshopLoginAdmin(firefox)
DBshopEnterMenu3(firefox, '商品管理', '管理分类','商品分类')
time.sleep(2)

#使用xpath轴定位，找到点击删除分类的控件
# 1.点击分类名称为“商品分类测试”后方的删除分类"链接
firefox.find_element_by_xpath("//td[contains(.,'%s')]/following-sibling::td[4]/a[3]"%goodsClassName).click()
time.sleep(2)
firefox.switch_to.alert.accept()
time.sleep(4)

#删除断言，与添加分类的断言相反，找不到元素说明已经成功
shijizhi=firefox.find_element_by_xpath\
    ("//td[contains(.,'%s')]/following-sibling::td[2]/input"%goodsClassName).get_property('value')
if shijizhi=="4":
    writeLog("%s 测试失败" % testCase)
else:
    writeLog("%s 测试成功" % testCase)
    getPhoto(firefox)
firefox.quit()

